/**
 *<p>Copyright: Copyright (c) 2012</p> 
 *<p>Company: SCPII</p>
 *<p>Project:scpii-api</p>
 *@author xiezhouyan
 *@Date 2013-5-15 下午8:06:05
 *@version 1.0
 *@description:
 */
package com.scpii.api.common.json.serializer;

import java.io.IOException;

import org.apache.commons.lang.StringUtils;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;

public class OptionValuesSerializer extends JsonSerializer<String[]> {

	@Override
	public void serialize(String[] value, JsonGenerator jgen,
			SerializerProvider provider) throws IOException,
			JsonProcessingException {
		jgen.writeStartArray();
		for (String val : value) {
			if (!StringUtils.isBlank(val)) {
				jgen.writeString(val);
			}
		}
		jgen.writeEndArray();
	}

}
